﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebRef = Sunboxsoft.ASMS.Client.Domain.WebRef;

namespace Sunboxsoft.ASMS.Client.UI
{
    static class Extension
    {
        /// <summary>
        /// 获取code，如果Item为null则返回null
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static string GetCode(this WebRef.EMasterDataItem item)
        {
            if (item == null)
            {
                return null;
            }
            return item.Code;
        }

        public static int GetCode(this Domain.IntCodeTextItem item, int defaultValue = 0)
        {
            if (item == null)
            {
                return defaultValue;
            }
            return item.Code;
        }

        public static Guid? GetId(this WebRef.VSupplier supplier)
        {
            if (supplier == null)
            {
                return null;
            }
            return supplier.Id;
        }

        public static Guid? GetStaffId(this WebRef.VStaffPosition vStaffPosition)
        {
            if (vStaffPosition == null)
            {
                return null;
            }
            return vStaffPosition.StaffId;
        }
    }
}
